<?php

namespace App\Jobs\Voter;

use App\Models\Voter\WxVoterPlayerBallot;
use App\Wen\Utils\UserUtils;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class SimulateVotePlayerJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    public $tries = 1;
    protected $player_id = 0;
    protected $voter_id = 0;
    protected $user_id = 0;
    protected $num = 0;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($user_id, $voter_id, $player_id ,$num)
    {
        //
        $this->user_id = $user_id;
        $this->voter_id = $voter_id;
        $this->player_id = $player_id;
        $this->num = $num;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {

        if( _empty_($this->num) || _empty_($this->player_id) ){
            return;
        }
        $ballot = new WxVoterPlayerBallot();
        $ballot->user_id = $this->user_id;
        $ballot->voter_id = $this->voter_id;
        $ballot->player_id = $this->player_id;
        $ballot->num = $this->num;
        $r = $ballot->save();
    }
}
